package com.foreknow.demo10;

/**
 * @author shkstart
 * @create 2021-07-29 13:13
 */

import java.util.Scanner;

/**
 * 封装类：主要用于数据类型的转换，每一种基本数据类型都会对应一种封装类型
 * 自动封装和拆封
 */
public class WrapDemo {
    public void m1(String s) {
        int num = Integer.parseInt(s);
        double d1 = Double.parseDouble(s);
        int sum = num + 1;
        System.out.println(num);
        System.out.println(sum);
        System.out.println(d1);
    }

    public void m2(Integer a) {  //封装
        int c = a + 12;   //a.intValue 相当于自动拆封
        System.out.println(c);

    }

    public static void main(String[] args) {
        Integer integer=new Integer(15);
        System.out.println(integer);
        Scanner input = new Scanner(System.in);
        System.out.println("请输入一个数：" + "\"a\"");
        String str1 = input.next();
        System.out.println("请输入一个数：" + "\"b\"");
        String str2 = input.next();
        int int1 = Integer.parseInt(str1);
        int int2 = Integer.parseInt(str2);
        System.out.println(int1 + int2);
        WrapDemo wrapDemo = new WrapDemo();
        wrapDemo.method1();
//        wrapDemo.m1("12");
        wrapDemo.m2(12);


        System.out.println("****************");

    }
    public void method1() {
        Integer i = new Integer(1);
        Integer j = new Integer(1);
        System.out.println(i == j);//false
        Integer m = 1;
        Integer n = 1;
        System.out.println(m == n);//true
        Integer x = 128;
        Integer y = 128;
        System.out.println(x == y);//false
    }
}
